package com.example.fw;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;

public class WebDriverHelper {
	
	private StringBuffer verificationErrors = new StringBuffer();
	protected static WebDriver driver;
	private final ApplicationManager manager;
	
	public WebDriverHelper(ApplicationManager manager) {
		this.manager =  manager;
		driver = new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		driver.get("http://localhost:8080/addressbook/");
	}
	
	public void stop() {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			Assert.fail(verificationErrorString);
		}
	}

	public WebDriver getDriver() {
		return driver;
	}
}
